package cn.lookup.controller;

import cn.lookup.pojo.Item;
import cn.lookup.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller("itemController")
@RequestMapping("/item")
public class ItemController {
    @Autowired
    @Qualifier("itemService")
    private ItemService itemService;
    @RequestMapping("/detail/{id}")
    public ModelAndView queryItemById(@PathVariable("id") int id, ModelAndView modelAndView){
        Item item = itemService.queryItemById(id);
        modelAndView.addObject("item",item);
        modelAndView.setViewName("detail");
        System.out.println(item);
        return modelAndView;
    }
}
